﻿using University.Workshop.Presenters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data;
using University.Workshop.Business;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    [TestClass()]
    public class PresenterProviderTest
    {


        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        #region SearchTests
        [TestMethod()]
        public void SearchTestValidNotNullEnable()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ValidSearchEnable();
            DataTable expected = new DataTable() { Locale = System.Globalization.CultureInfo.CurrentCulture };
            DataTable actual;
            actual = target.Search();
            Assert.AreNotEqual(expected, actual);
        }
        [TestMethod()]
        public void SearchTestValidNotNullDisable()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ValidSearchDisable();
            DataTable expected = new DataTable() { Locale = System.Globalization.CultureInfo.CurrentCulture };
            DataTable actual;
            actual = target.Search();
            Assert.AreNotEqual(expected, actual);
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void SearchTestValidNotResults()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ValidSearchNull();
            DataTable expected = new DataTable() { Locale = System.Globalization.CultureInfo.CurrentCulture };
            DataTable actual;
            actual = target.Search();

        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void SearchTestInvalidChars()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.SearchInvalidChars();
            DataTable expected = new DataTable() { Locale = System.Globalization.CultureInfo.CurrentCulture };
            DataTable actual;
            actual = target.Search();

        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void SearchEmptyTestInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.SearchEmpty();
            DataTable expected = new DataTable() { Locale = System.Globalization.CultureInfo.CurrentCulture };
            DataTable actual;
            actual = target.Search();

        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void SearchEmptyTestLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.SearchInvalidLenght();
            DataTable expected = new DataTable() { Locale = System.Globalization.CultureInfo.CurrentCulture };
            DataTable actual;
            actual = target.Search();

        }
        #endregion
        #region set
        [TestMethod()]
        public void SetProviderTest()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.SetProvider();
            bool actual = target.SetProvider();
            bool expected = true;
            Assert.AreEqual(expected, actual);
        }
        #endregion
        #region Updates
        [TestMethod()]
        public void UpdateProviderValid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderValid();
            bool actual = target.Update();
            Assert.AreEqual(true, actual);
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderNameInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderNameInvalid();
            bool actual = target.Update();
            Assert.AreEqual(true, actual);
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderNameLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderNameInvalidLenght();
            bool actual = target.Update();
            
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderNameEmpty()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderNameEmpty();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderAddressInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderAddressInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderAddressLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderAddressLenghtInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderAddressEmpty()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderAddressEmpty();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderTelephoneAndCellularEmpty()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderPhonesEmpty();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderTelephoneInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderTelephoneInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderCellularInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderCellularInvalid();
            bool actual = target.Update();
            
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderTelephoneLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderTelephoneLenghtInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderCellularLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderCellularLenghtInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderContactNameLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderContactNameLenghtInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderContactNameInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderContactNameInvalidChars();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderEmailInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderEmailInvalid();
            bool actual = target.Update();

        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderEmailLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderEmailLenghtInvalid();
            bool actual = target.Update();
        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderWebInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderWebInvalid();
            bool actual = target.Update();

        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void UpdateProviderWebLenghtInvalid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderWebLenghtInvalid();
            bool actual = target.Update();

        }
        /*[TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestNameNull()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateProviderNameNull();
               bool actual;
               actual = target.Update();
           }
           [TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestWhitoutCell()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateProviderWhitoutCell();
               bool actual;
               actual = target.Update();
           }
           /*[TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestNameInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateNameInvalid();
               bool actual;
               actual = target.Update();
           }
           [TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestAddressInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateAdressInvalid();
               DataTable actual;
               actual = target.Search();
           }
           [TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestTelephoneInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateProviderTelephoneInvalid();
               DataTable actual;
               actual = target.Search();
           }
           [TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestCellularInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateProviderCellularInvalid();
               DataTable actual;
               actual = target.Search();
           }
           [TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestContactInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateProviderContactInvalid();
               bool actual;
               actual = target.Update();
           }
           [TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestEmailInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateProviderEmailInvalid();
               bool actual;
               actual = target.Update();
           }
           /*[TestMethod()]
           [ExpectedException(typeof(BusinessException))]
           public void UpdateTestWebInvalid()
           {
               ProviderMockView view = new ProviderMockView();
               PresenterProvider target = new PresenterProvider(view);
               view.UpdateInvalidWeb();
               bool actual;
               actual = target.Update();
           }

           [TestMethod()]
           public void UpdateTestTrue()
           {
               ProviderMockView view=new ProviderMockView();
               PresenterProvider target=new PresenterProvider(view);
               view.UpdateTrue();
               bool actual = target.Update();
               bool expected = true;
               Assert.AreEqual(expected, actual);
           }*/
        #endregion
        [TestMethod()]
        public void DeleteAndEnableValid()
        {
            MockProvider view = new MockProvider();
            PresenterProvider target = new PresenterProvider(view);
            view.ModifyProviderValid();
            bool actual = target.DeleteProvider();
            target.EnableProvider();
            Assert.AreEqual(true, actual);

        }
    }
}
